GetChars(Int32,Int64,Char[],Int32,Int32) Method
In This Topic
Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset.
Syntax
Parameters
- i
- The zero-based column ordinal.
- fieldOffset
- The index within the row where the read operation is to begin.
- buffer
- The buffer into which to copy data.
- bufferOffset
- The index where buffer is to begin the write operation.
- length
- The maximum number of characters to read.
Return Value
The actual number of characters read.
Example
This sample shows how to read data from a field into array of chars.
static void GetThatChars(UniConnection myConnection)
{
UniCommand cmd = new UniCommand("SELECT * FROM Test.Dept");
cmd.Connection = myConnection;
myConnection.Open();
try
{
UniDataReader reader = cmd.ExecuteReader();
reader.Read();
char[] myChars = new char[50];
long bytesRead = reader.GetChars(reader.GetOrdinal("DName"),0,myChars,0,50);
Console.WriteLine(bytesRead+ " bytes read from the table.");
Console.WriteLine(myChars);
reader.Close();
}
finally
{
myConnection.Close();
}
}
Public Sub GetThatChars(ByVal myConnection As UniConnection)
Dim cmd As UniCommand = New UniCommand("SELECT * FROM Test.Dept")
cmd.Connection = myConnection
myConnection.Open()
Try
Dim reader As UniDataReader = cmd.ExecuteReader()
reader.Read()
Dim myChars(50) As Char
Dim bytesRead As Long = reader.GetChars(reader.GetOrdinal("DName"), 0, myChars, 0, 50)
Console.WriteLine(bytesRead & " bytes read from the table.")
Console.WriteLine(myChars)
reader.Close()
Finally
myConnection.Close()
End Try
End Sub
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also